﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Physio10Context;
using DatabaseManager;

namespace Physio_Clinic
{
    public partial class MedicalReportList : System.Web.UI.Page
    {
        Doctor doctor = null;
        public Qf8soUser currentUser = null;
        public int userId;
        Booking m_booking = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["currentUser"] != null)
            {
                currentUser = (Qf8soUser)Session["currentUser"];
                userId = (int)Session["currentUserId"];

            }
            if (!Page.IsPostBack)
            {
                CalendarOrder.SelectedDate = DateTime.Today;
            }
        }

        protected void GridSearchResultList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (GridSearchResultList.SelectedRow != null)
            {
                int index = GridSearchResultList.SelectedIndex;
                m_booking = PersistentManager.Instance.GetBooking(index);
                Session["Booking"] = m_booking;
                Response.Redirect("MedicalReport.aspx");
            }
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            /*
            Response.Write(e.CommandArgument);
            int rowNum = int.Parse(e.CommandArgument.ToString());
            GridViewRow row = GridSearchResultList.Rows[rowNum];
            string imageName = row.Cells[1].Text;
            Session["ScanImage"] = imageName;
            Response.Redirect("ShowImage.aspx");
            */
            if (e.CommandName == "seePic")
            {
                Response.Write(e.CommandArgument);
                int rowNum = int.Parse(e.CommandArgument.ToString());
                GridViewRow row = GridSearchResultList.Rows[rowNum];
                string imageName = row.Cells[1].Text;
                Session["ScanImage"] = imageName;
                Response.Redirect("ShowImage.aspx");
            }
            else
            {
                if (GridSearchResultList.SelectedRow != null)
                {
                    int index = GridSearchResultList.SelectedIndex;
                    m_booking = PersistentManager.Instance.GetBooking(index);
                    Session["Booking"] = m_booking;
                    Response.Redirect("MedicalReportEdit.aspx");
                }
            }
        }

        protected void Calendar1_SelectionChanged(object sender, EventArgs e)
        {

        }

    }
}